#ifndef _ACPI_H
#define _ACPI_H

#include <type.h>

#include "madt.h"
#include "sdt.h"

#define ACPI_RSDP_SIG_L 0x20445352 // 'RSD '
#define ACPI_RSDP_SIG_H 0x20525450 // 'PTR '

#define ACPI_MADT_SIG 0x43495041 // 'APIC'
#define ACPI_FADT_SIG 0x50434146 // 'FACP'

// 'MCFG' (Not part of ACPI standard. See PCI Firmware Spec.)
#define ACPI_MCFG_SIG 0x4746434d

/**
 * @brief Root System Description Pointer (RSDP)
 */
typedef struct ACPI_Root_System_Description_Pointer {
    u32 signature_l;
    u32 signature_h;
    u8 chksum;
    char oem_id[6];
    u8 rev;
    rsdt_t* rsdt;
    u32 length;
    sdth_t* xsdt;
    u8 x_chksum;
    char reserved[3]; // Reserved field
} packed rsdp_t;

typedef struct acpi_context {
    char oem_id[7];
    madt_ctx_t madt;
} acpi_ctx_t;

void acpi_init();

acpi_ctx_t* acpi_get_context();

#endif /* _ACPI_H */
